package com.jvup.gameshow.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.jvup.common.basic.StringUtil;
import com.jvup.common.constant.DeviceConfigInfo;
import com.jvup.common.constant.Navigation;
import com.jvup.common.inject.EventControllerInjector;
import com.jvup.common.inject.ViewModelInjector;
import com.jvup.common.model.entity.UserEntity;
import com.jvup.common.support.base.BaseActivity;
import com.jvup.common.support.base.BaseViewModel;
import com.jvup.common.utils.FileManager;
import com.jvup.gameshow.R;
import com.jvup.gameshow.controller.SystemSetupController;
import com.jvup.gameshow.databinding.ActivitySystemSetupBinding;
import com.jvup.gameshow.model.viewModel.ISystemSetupViewModel;
import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;

/**
 * 系统设置页
 */
@RouteMapping(path = Navigation.Page.SystemSetupPage)
public class SystemSetupActivity extends BaseActivity<ActivitySystemSetupBinding> {

    @Autowired(injector = ViewModelInjector.class)
    BaseViewModel<ISystemSetupViewModel> viewModel;

    @Autowired(injector = EventControllerInjector.class)
    SystemSetupController controller;

    @Override
    public int layoutRid() {
        return R.layout.activity_system_setup;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        controller.onAddition((ISystemSetupViewModel) viewModel);
    }

    @Override
    protected void onResume() {
        super.onResume();
        refreshUI();
    }

    private void refreshUI() {
        ISystemSetupViewModel iViewModel = (ISystemSetupViewModel) viewModel;
        iViewModel.setCacheCapacityHint(StringUtil.formatStorageSize(FileManager.countGlideCacheSize())); // "0MB"
//        iViewModel.setPrivacyProtocolRedDotVisible(DeviceConfigInfo.checkUpdatePrivacyProtocolVer() ? View.VISIBLE : View.GONE);
//        iViewModel.setVersion("版本:" + DeviceConfigInfo.info().versionName);
        iViewModel.setLoginOrLogoutBtnText(UserEntity.self.isLogin() ? "退出登录" : "立即登录");
    }

}
